package com.cci.kangdao.controller;

import com.cci.kangdao.model.condition.AuthInfoCondition;
import com.cci.kangdao.service.EmissionWarrantyService;
import com.cci.kangdao.utilTool.ParameterTool;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@RequestMapping("/ew")
public class EmissionWarrantyController {

    @Autowired
    private EmissionWarrantyService emissionWarrantyService;

    @RequestMapping(value = "getUrl.aspx", method = RequestMethod.GET)
    public void getUserIdAndToken() {
        emissionWarrantyService.getUserIdAndToken();
    }

    @RequestMapping(value = "getAuthInfo.aspx", method = RequestMethod.GET)
    public void getAuthInfo(HttpServletRequest request) throws Exception {
        Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
        String userId = MapUtils.getString(map, "userID");
        emissionWarrantyService.getAuthInfo(new AuthInfoCondition(userId, request.getHeader("token")));
    }

}
